<?php
$table = $this->uri->segment(3,0);
$url_ajax = base_url().'admin/ajax_field/order';
$url_ajax_sotrang = base_url().'admin/ajax_field/num';
$url_ajax_pub = base_url().'admin/ajax_field/pub/'.$table;
$url_ajax_where = base_url().'admin/ajax_field/where/'.$table;
?>
<?php include('ajax.php'); ?>
<div id="main-content">
    <div class="container">
    	<div class="row">
    		<div id="content" class="col-lg-12">
    			<!-- PAGE HEADER-->
                    <div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<div class="clearfix">
										<h3 class="content-title pull-left">Quản lí danh mục</h3>
									</div>
								</div>
							</div>
					</div>
                    <!-- DATA TABLES -->
						<div class="row">
							<div class="col-md-12">
								<!-- BOX -->
								<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>Danh sách môn học</h4>
										<div class="tools hidden-xs">
											<a href="javascript:;" data-toggle="tooltip" title="Ẩn đi" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
										</div>
									</div>
                                    <div class="row">
                                    <div class="col-md-12">
                                        <div class="pull-left padding10">
                                                <div id="datatable1_length" class="dataTables_length">
                                                    <label class="margin5">Hiện thị</label>
                                                    <select size="1" name="sotrang" id="sotrang" aria-controls="datatable1" class="inputbox form-control input-sm">
                                                        <?php 
                                                                for( $i=10;$i<=100;$i){ 
                                                                    echo '<option value="'.$i.'" ';
                                                                    if($this->session->userdata('limit')==$i){echo 'selected="selected"';}
                                                                    echo '>'.$i.'</option>';
                                                                    $i=$i+10;
                                                                }
                                                                for( $i=200;$i<=500;$i){ 
                                                                    echo '<option value="'.$i.'" ';
                                                                    if($this->session->userdata('limit')==$i){echo 'selected="selected"';}
                                                                    echo '>'.$i.'</option>';
                                                                    $i=$i+100;
                                                                }
                                                             
                                                        ?>
                                                    </select>
                                                </div>
                                        </div>
                                        <div class="pull-right padding10"><a href="<?php echo base_url().'admin/xuly/subjects/edit'; ?>" title="Thêm mới" class="btn btn-danger"><i class="fa fa-angle-double-right"></i>&nbsp;&nbsp;&nbsp;Thêm mới</a></div>
                                        </div>
                                    </div>
									<div class="box-body">
										<table id="datatable1" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
											<thead>
												<tr>
                                                    <th>ID</th>
													<th>Tên môn học</th>
													<th class="hidden-xs">Ngày tạo</th>
													<th class="center">Sắp xếp</th>
                                                    <th class="center">Ẩn / Hiện</th>
													<th class="center">Sửa</th>
													<th class="center">Xóa</th>
												</tr>
											</thead>
                                            <?php 
                                            if(!empty($cat)){
                                            foreach ($data as $data2){
                                            $mang[$data2->id]=$data2->title;
                                            }
                                            }
                                            $mang[0]="Danh mục gốc";
                                            if(!empty($data)){
                                                $i=0;
                                                foreach ($data as $data) : $i++;
                                            ?>
											<tbody>
												<tr class="gradeX">
													<td><?php echo $i;  ?></td>
													<td><?php if($data->parentid != 0) { echo '----';} echo $data->title;  ?></td>
													<td class="center hidden-xs"><?php echo $data->create;  ?></td>
													<td class="center"><?php echo $data->order;  ?></td>
                                                    <td class="center"> <?php 
                                                        if($data->publish)
                                                        {
                                                            echo '<p class="ajax_hien" id="p'.$data->id.'" name="'.$table.'/publish/'.$data->id.'/p'.$data->id.'" ><i style="color:green;" class="fa fa-check-circle fa-2x"></i></p>';
                                                        }
                                                        else
                                                        {
                                                            echo '<p  id="p'.$data->id.'" class="ajax_hien unpublish" id="unpublish" name="'.$table.'/publish/'.$data->id.'/p'.$data->id.'"><i style="color:red;" class="fa fa-times-circle-o fa-2x"></i></p>';
                                                        }
                                                    ?></td>
													<td class="center"><a href="<?php echo base_url().'admin/xuly/subjects/edit/'.$data->id?>" title="Sửa môn học <?php echo $data->title;  ?>"><i class="fa fa-edit fa-2x"></i></a></td>
                                                    <td class="center"><a onclick="return confirm('Bạn có muốn xóa không?');" href="<?php echo base_url().'admin/xuly/subjects/xoa/'.$data->id?>" title="Xóa môn học <?php echo $data->title;  ?>"><i class="fa fa-trash-o fa-2x red"></td>
												</tr>
											</tbody>
                                            <?php endforeach; } ?>
										</table>
			                             <div class="row">
                                               <div class="col-sm-12">
                                                  <div class="pull-right">
                                                           <?php echo $this->pagination->create_links();?>
                                                  </div>
                                                  <div class="clearfix"></div>
                                               </div>
                                            </div>
                                    </div>
								</div>
								<!-- /BOX -->
							</div>
						</div>
						<!-- /DATA TABLES -->
   			</div>
    			<!-- /PAGE HEADER -->
    		</div>
    	</div>
</div>